#ifndef CURRENTSOURCE_H
#define CURRENTSOURCE_H

#include <QObject>
#include <QSerialPort>
#include "serialcore.h"
#include <QThread>
class CurrentSource : public QObject
{
    Q_OBJECT
public:
    explicit CurrentSource(QObject *parent = nullptr);
    ~CurrentSource();
    SerialCore *serialCoreObject;
    QThread mThread;
    void SlotsInit();
    void OpenDevice();//外部调用 打开设备
    void CloseDevice();//外部调用 关闭设备
    void SendData(QByteArray sendData,int recvLength);//外部调用 发送数据
    QByteArray RecvData();//外部调用 接收返回数据
    unsigned short cal_crc(unsigned char *ptr, unsigned char len);
    bool Send0A();
    bool Send50A();
    bool hasRecv=false;//接收完返回数据标志位
    QByteArray recvBuf;//返回数据存储buf
    void TestCrc();
signals:
    void ToCreateDevice();//创建对象的信号
    void ToOpenDevice();//打开设备的信号
    void ToCloseDevice();//关闭设备的信号
    void ToSendData(QByteArray sendData,int recvLength);//发送数据的信号
    void ToShowSendRecvData(QString);
    void ToShowOpenDeviceStatus(QString);
public slots:
    void Slot_CreateDevice();
    void Slot_OpenDevcie();
    void Slot_CloseDevice();
    void Slot_SendData(QByteArray sendData,int recvLength);


};

#endif // CURRENTSOURCE_H
